public class Draw {
    // 属性：高度，至少超过3行
    private int height;

    // 构造方法
    public Draw(int height) {
        if (height < 3) {
            throw new IllegalArgumentException("高度至少超过3行");
        }
        this.height = height;
    }

    // 绘制三角形
    public void drawTriangle() {
        for (int i = 1; i <= height; i++) {
            for (int j = 1; j <= height - i; j++) {
                System.out.print(" ");
            }
            for (int k = 1; k <= (2 * i - 1); k++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    // 绘制矩形
    public void drawRectangle(int width) {
        for (int i = 1; i <= height; i++) {
            for (int j = 1; j <= width; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    // 绘制正方形
    public void drawSquare() {
        drawRectangle(height);
    }

    // 绘制平行四边形（倾斜角度为45度）
    public void drawParallelogram() {
        for (int i = 1; i <= height; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print(" ");
            }
            for (int k = 1; k <= height * 2 - 1; k++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    public static void main(String[] args) {
        // 创建Draw类对象，高度为5
        Draw draw = new Draw(5);

        // 绘制三角形
        System.out.println("绘制三角形:");
        draw.drawTriangle();
        System.out.println();

        // 绘制矩形（宽度为8）
        System.out.println("绘制矩形:");
        draw.drawRectangle(8);
        System.out.println();

        // 绘制正方形
        System.out.println("绘制正方形:");
        draw.drawSquare();
        System.out.println();

        // 绘制平行四边形
        System.out.println("绘制平行四边形:");
        draw.drawParallelogram();
    }
}